package com.dbq.fast.business.setting;

import android.util.Log;

import com.dbq.fast.BuildConfig;
import com.dbq.fast.business.me.bean.ActiveMoney;
import com.dbq.fast.business.me.bean.VersionBean;
import com.dbq.fast.business.me.bean.WithdrawInfo;
import com.dbq.fast.business.product.api.CommonTransformer;
import com.dbq.fast.business.ypage.YPageBean;
import com.dbq.fast.common.bean.User;
import com.dbq.fast.common.net.HttpManager;
import com.dbq.fast.common.net.LogHttpManager;
import com.dbq.fast.common.net.RemoteApiCallBack;

import java.util.HashMap;

import okhttp3.RequestBody;
import okhttp3.ResponseBody;

/**
 * Created by yuanchen on 2018/5/4.
 */

public class SettingApi {

    private static HttpManager httpManager = HttpManager.getInstance();


    public static void checkUpdate(RemoteApiCallBack<VersionBean> c) {
        httpManager.getHttpService()
                .checkVersion(User.getInstance().getToken(),User.getInstance().getVpnId(), BuildConfig.VERSION_NAME)
                .compose(new CommonTransformer<>())
                .subscribe(rewardInfoHttpResult -> {
                    if (rewardInfoHttpResult.isSuccess()) {
                        c.onSuccess(rewardInfoHttpResult.getData());
                    } else {

                    }
                }, throwable -> {
                    Log.i("throwable", throwable.toString());
                });
    }

    public static void downloadApk(final String url, RemoteApiCallBack<ResponseBody> c) {
        String vpnId = User.getInstance().getVpnId();
        HashMap body = new HashMap();
        httpManager.getHttpService()
                .downloadApk(url)
                .compose(new CommonTransformer<>())
                .subscribe(res -> {
                    c.onSuccess(res);
                }, throwable -> {
                    Log.i("throwable", "throwable = " + throwable.toString());
                });
    }


}
